package com.ztz.mynewdemo;

import android.app.Application;
import android.content.Context;

import com.avos.avoscloud.AVOSCloud;
import com.baidu.mapapi.SDKInitializer;
import com.facebook.stetho.Stetho;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import com.tencent.bugly.crashreport.CrashReport;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

/**
 * Created by wqewqe on 2017/5/16.
 */

public class App extends Application {
    private static  App app;
    Context context;
    private RefWatcher refWatcher;
    @Override
    public void onCreate() {
        super.onCreate();
        Stetho.initializeWithDefaults(this);
        SDKInitializer.initialize(this);
        context=getApplicationContext();
        PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
        PlatformConfig.setQQZone("1106585557", "4YTA4oujlMhSeMhe");
        PlatformConfig.setSinaWeibo("1309837785", "489cb5dce374c966a4d4cc70c6f4f872", "http://sns.whalecloud.com");
        UMShareAPI.get(this);
        Config.DEBUG = true;
        AVOSCloud.initialize(this,"Fkaab1ktpqbWBJyufu0Regpd-gzGzoHsz","LuF6Ry6MARcH4ByMPg9M8vOF");
        AVOSCloud.setDebugLogEnabled(true);
        app=this;
        if(LeakCanary.isInAnalyzerProcess(this)){
            return;
        }
        //LeakCanary 内存泄漏监控
//        refWatcher=setupLeakCanary();
//        //只能检测Activity内存泄漏
//        LeakCanary.install(this);
        CrashReport.initCrashReport(getApplicationContext(), "8b66310b27", true);
    }
    public static RefWatcher getRefWatcher(Context context){
        App app= (App) context.getApplicationContext();
        return app.refWatcher;
    }
    private RefWatcher setupLeakCanary(){
        if(LeakCanary.isInAnalyzerProcess(this)){
            return RefWatcher.DISABLED;
        }
        return LeakCanary.install(this);
    }
    public Context getContext(){
        return context;
    }
    public static App getInstance()
    {
        return  app;
    }
}
